import LoadingVue from './index.vue'

const Loading = {};

Loading.install = function (Vue, option) {
  const LoadingInstance = Vue.extend(LoadingVue);
  let name,nameSpan;
  const initInstance = () => {
    name = new LoadingInstance();
    nameSpan = name.$mount().$el;
    document.body.appendChild(nameSpan);
  }
  const remove = () => {
    // name = new LoadingInstance();//name 在初始化时定义，这里不能定义，否则删除会出错
    // let nameSpan = name.$mount().$el;
    document.body.removeChild(nameSpan);
  }
  Vue.prototype.$Loading = {
    LoadingShowHide(option){
        if(option){
            initInstance();
        }else{
            remove();
        }
        return initInstance;
    }
  };
}

export default Loading;
